/*
 * File:   Sphere.h
 * Author: jcrada
 *
 * Created on 26 May 2011, 1:02 PM
 */

#ifndef ECB_SPHERE_H
#define	ECB_SPHERE_H

#include "ecb/base/Problem.h"

namespace ecb {

    /* Source:
     * @incollection{springer-dif.evo,
     Author = {Price, Kenneth and Storn, Rainer M. and Lampinen, Jouni A.},
     title={{Appendix}},
     booktitle = {Differential Evolution: A Practical Approach to Global Optimization},
     series={Natural Computing Series},
     editor={Rozenberg, G. and Bäck, Th. and Eiben, A. E. and Kok, J. N. and Spaink, H. P.},
     publisher = {Springer-Verlag Berlin Heidelberg},
     pages = {513-533},
     year = {2005}
     }
     */
    class Sphere : public Problem {
    public:

        Sphere(const std::string& id = "Sphere", const std::string& name = "Sphere",
                int dimensions = 0, scalar minimum = -5.12, scalar maximum = 5.12,
                bool minimization = true) :
        Problem(id, name, dimensions, minimum, maximum, minimization) { }

        scalar f(const std::vector<scalar>& x) {
            scalar result = 0.0;
            for (size_t i = 0; i < x.size(); ++i) {
                result += x[i] * x[i];
            }
            return result;
        }
    };
}


#endif	/* ECB_SPHERE_H */

